<template>
    <div class="productMsg" v-html="details"></div>
</template>
<style lang="less">
    @import "../static/css/productDetail/productMsg.less";
</style>
<script>
    export default{
        data() {
            return {
                id:1,
                //商品详情信息
                details:""
            }
        },
        methods:{
            //获取商品的id
            getProductId:function(){
                if(this.$route.query.id) {
                    this.id = this.$route.query.id;
                }
            },
            //请求商品详情的信息
            getProductDetail:function(){
                // this.$http.get("http://127.0.0.1:3000/getproductdetail?id=1")
                this.$http.get(`http://39.108.173.168:8888/api/product?id=${this.id}`)
                    .then((data) => {
                        this.details = data.data.details;
                    });
            }
        },
        created(){
            this.getProductId();
            this.getProductDetail();
        }
    }
</script>

